package com._520it.crm.service.impl;

import com._520it.crm.domain.Client;
import com._520it.crm.domain.Department;
import com._520it.crm.domain.Employee;
import com._520it.crm.mapper.DepartmentMapper;
import com._520it.crm.mapper.EmployeeMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.DepartmentQueryObject;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IDepartmentService;
import com._520it.crm.service.IEmployeeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by ASUS on 2017/10/9.
 */
@Service
public class DepartmentServiceImpl implements IDepartmentService{

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Department record) {
        return departmentMapper.insert(record);
    }

    @Override
    public Department selectByPrimaryKey(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Department record) {
        return departmentMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult query(DepartmentQueryObject qo) {
        Integer totalCount = departmentMapper.queryforCount(qo);
        if(totalCount==0){
            return  new PageResult(0,Collections.EMPTY_LIST);

        }
        List<Department> data = departmentMapper.queryforList(qo);
        return new PageResult(totalCount,data);
    }
}
